package interviewClassic150;

public class MaxArea {
    public int maxArea(int[] height) {
        //左右两个指针
        int left =0;
        int right = height.length - 1;
        int res = 0;
        while (left < right) {
            int h = Math.min(height[left],height[right]);
            int w = right - left;
            int curArea = h * w;
            res = Math.max(curArea,res);
            //每次移动都移动高度相对较小的那个
            if (height[left] < height[right]) left++;
            else right--;
        }

        return res;
    }
}
